<div class="row">
    <div class="col-xs-12 col-xs-12">
        <div class="widget radius-bordered">
            <div class="widget-header bg-blue">
                <i class="widget-icon fa fa-arrow-down"></i>
                <span class="widget-caption">添加角色</span>
            </div>
            <div class="widget-body">
                <form id="AppForm" action="" method="post" class="form-horizontal" data-bv-message="" data-bv-feedbackicons-valid="glyphicon glyphicon-ok" data-bv-feedbackicons-invalid="glyphicon glyphicon-remove" data-bv-feedbackicons-validating="glyphicon glyphicon-refresh">
                    <div class="form-title">
                        <a href="{:url('dlc/role/roleList')}" class="btn btn-primary" data-loader="App-loader" data-loadername="角色权限列表">
                            <i class="fa fa-mail-reply"></i>返回
                        </a>
                    </div>
                    <input type="hidden" name="id" value="{$role.id}" />
                    <div class="form-group">
                        <label class="col-lg-2 control-label">角色名称：<sup>*</sup></label>
                        <div class="col-lg-6" >
                            <input type="text" class="form-control"  name="name" placeholder="必填" data-bv-notempty="true" data-bv-notempty-message="不能为空" value="{$role.name}" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-2 control-label">角色描叙 :</label>
                        <div class="col-lg-6" >
                            <textarea class="form-control" rows="3" name="desc" placeholder="角色描叙内容" >{$role.desc}</textarea>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-2 control-label">角色菜单权限：<sup>*</sup></label>
                        <div class="col-lg-6" style="border:1px solid #ccc;padding-top: 10px; margin-left: 15px;">
                            {volist name="menuLevel1" id="vo"}
                            <ul style="list-style:none;">
                                <label>
                                    <input {eq name="vo['id']" value="1"} disabled {/eq} type="checkbox" pid="{$vo['id']}" class="colored-blue oa-check pid" {in name="vo.id" value="$roleMenuIds"} checked="checked" {/in} value="{$vo.id}" data-label="{$vo.name}">
                                    <span class="text">{$vo.name}&nbsp;&nbsp;&nbsp;&nbsp;</span>
                                </label>
                                <li style="margin-left: 30px;">
                                    {volist name="menuLevel2" id="bo" key="k"}
                                    {eq name="bo['menu_pid']" value="$vo['id']" }
                                    <label>
                                        <input type="checkbox" {eq name="bo['menu_pid']" value="1"} disabled {/eq} class="colored-blue oa-check pid_{$bo['menu_pid']}" {in name="bo.id" value="$roleMenuIds"} checked="checked" {/in} value="{$bo.id}" data-label="{$bo.name}">
                                        <span class="text">{$bo.name}&nbsp;&nbsp;&nbsp;&nbsp;</span>
                                    </label>
                                    {/eq}
                                    {/volist}
                                </li>
                            </ul>
                            {/volist}
                        </div>
                        <!--角色权限数据-->
                        <input type="hidden" name="menuIds" id="menuIds" value="" />
                    </div>
                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                            <button class="btn btn-primary btn-lg" type="submit">保存</button>&nbsp;&nbsp;
                            <button class="btn btn-palegreen btn-lg" type="reset">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>

</div>

<!--表单验证与提交封装-->
<script type="text/javascript">
    $('#AppForm').bootstrapValidator({
        submitHandler: function (validator, form, submitButton) {

            var checks=$('.oa-check');

            var menuIds = new Array();

            $(checks).each(function(){
                if($(this).is(":checked")){
                    menuIds.push($(this).val());
                }
            });

            $('#menuIds').val(menuIds);

            var tourl="{:url('dlc/role/roleEdit')}";
            var data=$('#AppForm').serialize();
            $.App.ajax('post',tourl,data,null);
            return false;
        },
    });

    $('.pid').click(function(){
        var pid = $(this).attr('pid');
        if($(this).is(":checked")) {
            $('.pid_'+pid).prop('checked',true);
        } else {
            $('.pid_'+pid).prop('checked',false);
        }
    })

</script>
<!--/表单验证与提交封装-->
